##########################################################################################
###                             ### REPLICATION DO FILE ###                            ###
##########################################################################################

##########################################################################################
### "The responsive public: How EU decisions shape public opinion on salient policies" ###
### Author: Christoph Mikulaschek                                                      ###
### Forthcoming in: European Union Politics                                            ###
### Date: 6/15/2023                                                                    ###
##########################################################################################

### Note: Most analyses can be replicated with STATA replication do file. Only a few analyses, which are listed in the STATA do file, were conducted in R and can be replicated with this replication do file.

### Note: Load correct dataset before replicating analyses: 
###   - recoveryaid.csv: for analyses of Coronavirus economic recovery aid experiment
###   - refugeerelocation.csv: for analyses of refugee relocation experiment
###   - eurobarometer-subset.csv: for quasi-experimental analyses of Eurobarometer data 

library(car)
library(lsr)
library(stats)

### Figures in main text and online appendix
############################################

### Figure 1 in the main text

# Note: Please refer to STATA replication do file for calculation of predicted probabilities shown in plot

library(graphics)
xlabel <- c("EU Council\napproval", "EU Council\nnon-approval")
xlabel.2 <- c("Coronavirus recovery aid")
xlabel.3 <- c("Refugee relocation")
ytickmarks <- seq(0.4, 0.7, 0.05)
ylabels <- seq(0.5, 0.7, 0.1)
par(mar=c(12.5, 10, 8, 3)) # set to size 2500 x 2000
plot(1, type="n", xaxt = 'n', yaxt = 'n', xlab="", ylab="", xlim=c(0.5, 5.5), ylim=c(0.45, .65))
box(lwd = 3) 
for(i in 1:20){
  abline(h=i/20, col = "grey", lty = 3, lwd = 3)
}
points(x = 1, y = .5675865, pch = 19, cex = 6) # Coronavirus recovery aid, EU Council approval
points(x = 2, y = .5176745, pch = 19, cex = 6) # Coronavirus recovery aid, EU Council non-approval
points(x = 4, y = .5488924 , pch = 19, cex = 6) # refugee relocation, EU Council approval
points(x = 5, y = .5239871, pch = 19, cex = 6) # refugee relocation, EU Council non-approval
lines(x = c(1, 1), y = c(.5548228, .5803502), lwd = 4) #95% CI 
lines(x = c(2, 2), y = c(.5049808, .5303683), lwd = 4) #95% CI 
lines(x = c(4, 4), y = c(.5353939, .562391), lwd = 4) #95% CI 
lines(x = c(5, 5), y = c(.5103356, .5376387), lwd = 4) #95% CI 
mtext(side = 3, xlabel.2, at = c(1.5), cex = 4,font = 2, line = 1)
mtext(side = 3, xlabel.3, at = c(4.5), cex = 4,font = 2, line = 1)
mtext(side = 1, xlabel, at = c(1, 2, 4, 5), cex = 4, line = 11)
axis(side = 2, at = ytickmarks, labels = NA, cex.axis = 4, lwd = 4, lwd.ticks = 4, line = 0) 
mtext(ylabels, side = 2, at = ylabels, line = 3, cex = 4)
mtext("Predicted likelihood of favoring refugee/ economic aid policies", side = 2, line = 7, cex = 4)
mtext("", side = 3, line = 5, cex = 4, font = 2)

### Figure 2 in main text

# Note: Please refer to STATA replication do file for calculation of predicted probabilities shown in plot

# Economic recovery aid experiment 
trust <- read.csv("trust_aid.csv", header = TRUE)
line.hor <- seq(1, 3, 1)
xlab.trust <- c("Completely or largely", "Moderately", "A little bit or not at all")
xlabel.2 <- c("Coronavirus recovery aid")
par(mar=c(12.5, 13.5, 4, 0.5)) # set to size 2500 x 2000
plot(1, type="n", xaxt = 'n', yaxt = 'n', xlab="", ylab="", xlim=c(0.67, 3.33), ylim=c(0.4, 0.75))
box(lwd = 3) 
for(i in 1:10){
  abline(h=i/10, col = "grey", lty = 3, lwd = 3)
}
polygon(c(line.hor, rev(line.hor)), c(trust$noapp.ci.lower, rev(trust$noapp.ci.upper)),
        col = "darkorange", border = NA)
polygon(c(line.hor, rev(line.hor)), c(trust$app.ci.lower, rev(trust$app.ci.upper)),
        col = "blue3", border = NA)
rect(0, 0, 1, 1, density = NULL, col = "white", border = NA)
rect(3, 0, 4, 1, density = NULL, col = "white", border = NA)
box(lwd = 3) 
lines(x = c(1, 3), y = c(trust$noapp[1], trust$noapp[3]), lwd = 5) #point estimate: EU Council non-approval
lines(x = c(1, 3), y = c(trust$app[1], trust$app[3]), lwd = 5) #point estimate: EU Council approval
axis(side = 1, at = seq(1, 3, 1), labels = NA, line = 1, padj = 0, cex.axis = 4, lwd = 3, lwd.ticks = 3)
mtext(xlab.trust, side = 1, at = seq(1, 3, 1), line = 4, cex = 4)
mtext("Trust EU Council's judgment?", side = 1, at = 2, line = 9, padj = 0, cex = 4)
axis(side = 2, at = seq(0.4, 0.8, 0.1), labels = seq(0.4, 0.8, 0.1), line = 1, padj = 0, cex = 4, cex.axis = 4, cex.lab = 4, lwd = 3, lwd.ticks = 3)
mtext("Predicted support for economic recovery aid", side = 2, at = 0.55, line = 8, padj = 0, cex = 4)
mtext(side = 3, xlabel.2, at = 2, cex = 4,font = 2, line = 1)
text(x = 2.0, y = 0.817-.1, "Policy endorsed by Council of EU", col = "blue3", cex = 4, pos = 4)
text(x = 2.0, y = 0.783-.1, "Policy not endorsed by Council of EU", col = "darkorange", cex = 4, pos = 4)
segments(1.8, 0.817-.1, 1.95, 0.817-.1, lwd = 4, col = "blue3")
segments(1.8, 0.783-.1, 1.95, 0.783-.1, lwd = 4, col = "darkorange")

# Refugee relocation experiment (3-point DV)
trust <- read.csv("trust_ref.csv", header = TRUE)
line.hor <- seq(1, 3, 1)
xlab.trust <- c("Completely or largely", "Moderately", "A little bit or not at all")
xlabel.2 <- c("Refugee relocation")
par(mar=c(12.5, 13.5, 4, 0.5)) # set to size 2500 x 2000
plot(1, type="n", xaxt = 'n', yaxt = 'n', xlab="", ylab="", xlim=c(0.67, 3.33), ylim=c(0.4, 0.75))
box(lwd = 3) 
for(i in 1:10){
  abline(h=i/10, col = "grey", lty = 3, lwd = 3)
}
polygon(c(line.hor, rev(line.hor)), c(trust$noapp.ci.lower, rev(trust$noapp.ci.upper)),
        col = "darkorange", border = NA)
polygon(c(line.hor, rev(line.hor)), c(trust$app.ci.lower, rev(trust$app.ci.upper)),
        col = "blue3", border = NA)
rect(0, 0, 1, 1, density = NULL, col = "white", border = NA)
rect(3, 0, 4, 1, density = NULL, col = "white", border = NA)
box(lwd = 3) 
lines(x = c(1, 3), y = c(trust$noapp[1], trust$noapp[3]), lwd = 5) #point estimate: EU Council non-approval
lines(x = c(1, 3), y = c(trust$app[1], trust$app[3]), lwd = 5) #point estimate: EU Council approval
axis(side = 1, at = seq(1, 3, 1), labels = NA, line = 1, padj = 0, cex.axis = 4, lwd = 3, lwd.ticks = 3)
mtext(xlab.trust, side = 1, at = seq(1, 3, 1), line = 4, cex = 4)
mtext("Trust EU Council's judgment?", side = 1, at = 2, line = 9, padj = 0, cex = 4)
axis(side = 2, at = seq(0.4, 0.8, 0.1), labels = seq(0.4, 0.8, 0.1), line = 1, padj = 0, cex = 4, cex.axis = 4, cex.lab = 4, lwd = 3, lwd.ticks = 3)
mtext("Predicted support for refugee relocation", side = 2, at = 0.55, line = 8, padj = 0, cex = 4)
mtext(side = 3, xlabel.2, at = 2, cex = 4,font = 2, line = 1)
text(x = 2.0, y = 0.817-.1, "Policy endorsed by Council of EU", col = "blue3", cex = 4, pos = 4)
text(x = 2.0, y = 0.783-.1, "Policy not endorsed by Council of EU", col = "darkorange", cex = 4, pos = 4)
segments(1.8, 0.817-.1, 1.95, 0.817-.1, lwd = 4, col = "blue3")
segments(1.8, 0.783-.1, 1.95, 0.783-.1, lwd = 4, col = "darkorange")

### Figure 3 in main text

# Note: Please refer to STATA replication do file for calculation of predicted probabilities shown in plot

library(graphics)
xlabel <- c("unani-\nmity", "approval&\ndissent", "vetoes", "broad\nopposition")
xlabel.2 <- c("Coronavirus recovery aid")
xlabel.3 <- c("Refugee relocation")
ytickmarks <- seq(0.4, 0.7, 0.05)
ylabels <- seq(0.5, 0.7, 0.1)
par(mar=c(12.5, 10, 8, 3)) # set to size 2500 x 2000
plot(1, type="n", xaxt = 'n', yaxt = 'n', xlab="", ylab="", xlim=c(0.5, 9.5), ylim=c(0.45, .65))
box(lwd = 3) 
for(i in 1:20){
  abline(h=i/20, col = "grey", lty = 3, lwd = 3)
}
points(x = 1, y = 0.584979, pch = 19, cex = 6) # aid, pooled, unanimity
points(x = 2, y = 0.5505314, pch = 19, cex = 6) # aid, pooled, dissent
points(x = 3, y = 0.5270927 , pch = 19, cex = 6) # aid, pooled, veto
points(x = 4, y = 0.5083604, pch = 19, cex = 6) # aid, pooled, opposition
points(x = 6, y = 0.5469119, pch = 19, cex = 6) # refugee, pooled, unanimity
points(x = 7, y = 0.5508471, pch = 19, cex = 6) # refugee, pooled, dissent
points(x = 8, y = 0.5476521, pch = 19, cex = 6) # refugee, pooled, veto
points(x = 9, y = 0.5003013, pch = 19, cex = 6) # refugee, pooled, opposition
abline(h = 0, lty = 3, lwd = 4)
lines(x = c(1, 1), y = c(0.5665529, 0.6034052), lwd = 4) #95% CI aid
lines(x = c(2, 2), y = c(0.5328932, 0.5681695), lwd = 4) #95% CI aid
lines(x = c(3, 3), y = c(0.509005, 0.5451804), lwd = 4) #95% CI aid 
lines(x = c(4, 4), y = c(0.4905435, 0.5261774), lwd = 4) #95% CI aid
lines(x = c(6, 6), y = c(0.5274305, 0.5663934), lwd = 4) #95% CI refugee
lines(x = c(7, 7), y = c(0.5321529, 0.5695412), lwd = 4) #95% CI refugee
lines(x = c(8, 8), y = c(0.5284945, 0.5668097), lwd = 4) #95% CI refugee
lines(x = c(9, 9), y = c(0.4809441, 0.5196585), lwd = 4) #95% CI refugee
mtext(side = 3, xlabel.2, at = c(2.5), cex = 4,font = 2, line = 1)
mtext(side = 3, xlabel.3, at = c(7.5), cex = 4,font = 2, line = 1)
mtext(side = 1, xlabel, at = c(0.8, 1.9, 3.1, 4.2, 5.8, 6.9, 8.1, 9.2), cex = 4, line = 11)
axis(side = 2, at = ytickmarks, labels = NA, cex.axis = 4, lwd = 4, lwd.ticks = 4, line = 0) 
mtext(ylabels, side = 2, at = ylabels, line = 3, cex = 4)
mtext("Predicted likelihood of favoring refugee/ economic aid policies", side = 2, line = 7, cex = 4)
mtext("", side = 3, line = 5, cex = 4, font = 2)

### Figure 4 in the main text

# Note: Please refer to STATA replication do file for calculation of predicted probabilities shown in plot

trust <- read.csv("trust_eurobarometer.csv", header = TRUE)
line.hor <- seq(1, 4, 1)
xlab.trust <- c("Totally", "Tend to", "Tend not to", "Not at all")
xlabel.2 <- c("Coronavirus recovery aid")

par(mar=c(12.5, 13.5, 4, 0.5)) # set to size 2500 x 2000
plot(1, type="n", xaxt = 'n', yaxt = 'n', xlab="", ylab="", xlim=c(0.67, 4.33), ylim=c(0.05, 0.30))
box(lwd = 3) 
for(i in 1:20){
  abline(h=i/20, col = "grey", lty = 3, lwd = 3)
}
polygon(c(line.hor, rev(line.hor)), c(trust$noapp.ci.lower, rev(trust$noapp.ci.upper)),
        col = "darkorange", border = NA)
polygon(c(line.hor, rev(line.hor)), c(trust$app.ci.lower, rev(trust$app.ci.upper)),
        col = "blue3", border = NA)
rect(0, 0, 1, 1, density = NULL, col = "white", border = NA)
rect(4, 0, 5, 1, density = NULL, col = "white", border = NA)
box(lwd = 3) 
lines(x = c(1, 4), y = c(trust$before[1], trust$before[4]), lwd = 5) #point estimate: before European Council decision
lines(x = c(1, 4), y = c(trust$after[1], trust$after[4]), lwd = 5) #point estimate: after European Council decision
axis(side = 1, at = seq(1, 4, 1), labels = NA, line = 1, padj = 0, cex.axis = 4, lwd = 3, lwd.ticks = 3)
mtext(xlab.trust, side = 1, at = seq(1, 4, 1), line = 4, cex = 4)
mtext("Trust EU's judgment?", side = 1, at = 2.5, line = 9, padj = 0, cex = 4)
axis(side = 2, at = seq(0.0, 0.3, 0.05), labels = seq(0.0, 0.3, 0.05), line = 1, padj = 0, cex = 4, cex.axis = 4, cex.lab = 4, lwd = 3, lwd.ticks = 3)
mtext("Predicted support for economic recovery aid", side = 2, at = 0.175, line = 8, padj = 0, cex = 4)
mtext(side = 3, xlabel.2, at = 2.5, cex = 4,font = 2, line = 1)
text(x = 1.8, y = 0.29, "After policy endorsement by European Council", col = "blue3", cex = 4, pos = 4)
text(x = 1.8, y = 0.275, "Before policy endorsement by European Council", col = "darkorange", cex = 4, pos = 4)
segments(1.6, 0.29, 1.75, 0.29, lwd = 4, col = "blue3")
segments(1.6, 0.275, 1.75, 0.275, lwd = 4, col = "darkorange")

### Figure A.2 in online appendix

# Note: Please refer to STATA replication do file for calculation of predicted probabilities shown in plot

# Economic recovery aid experiment
trust <- read.csv("trust_aid_5pointscale.csv", header = TRUE)
line.hor <- seq(1, 5, 1)
xlab.trust <- c("Completely", "Largely", "Moderately", "A little bit", "Not at all")
xlabel.2 <- c("Coronavirus recovery aid")
par(mar=c(12.5, 13.5, 4, 0.5)) # set to size 2500 x 2000
plot(1, type="n", xaxt = 'n', yaxt = 'n', xlab="", ylab="", xlim=c(0.67, 5.33), ylim=c(0.35, 0.8))
box(lwd = 3) 
for(i in 1:10){
  abline(h=i/10, col = "grey", lty = 3, lwd = 3)
}
polygon(c(line.hor, rev(line.hor)), c(trust$noapp.ci.lower, rev(trust$noapp.ci.upper)),
        col = "darkorange", border = NA)
polygon(c(line.hor, rev(line.hor)), c(trust$app.ci.lower, rev(trust$app.ci.upper)),
        col = "blue3", border = NA)
rect(0, 0, 1, 1, density = NULL, col = "white", border = NA)
rect(5, 0, 6, 1, density = NULL, col = "white", border = NA)
box(lwd = 3) 
lines(x = c(1, 5), y = c(trust$noapp[1], trust$noapp[5]), lwd = 5) #point estimate: EU Council non-approval
lines(x = c(1, 5), y = c(trust$app[1], trust$app[5]), lwd = 5) #point estimate: EU Council approval
axis(side = 1, at = seq(1, 5, 1), labels = NA, line = 1, padj = 0, cex.axis = 4, lwd = 3, lwd.ticks = 3)
mtext(xlab.trust, side = 1, at = seq(1, 5, 1), line = 4, cex = 4)
mtext("Trust EU Council's judgment?", side = 1, at = 3, line = 9, padj = 0, cex = 4)
axis(side = 2, at = seq(0.4, 0.8, 0.1), labels = seq(0.4, 0.8, 0.1), line = 1, padj = 0, cex = 4, cex.axis = 4, cex.lab = 4, lwd = 3, lwd.ticks = 3)
mtext("Predicted support for economic recovery aid", side = 2, at = 0.6, line = 8, padj = 0, cex = 4)
mtext(side = 3, xlabel.2, at = 3, cex = 4,font = 2, line = 1)
text(x = 3.0, y = 0.817-.1, "Policy endorsed by Council of EU", col = "blue3", cex = 4, pos = 4)
text(x = 3.0, y = 0.783-.1, "Policy not endorsed by Council of EU", col = "darkorange", cex = 4, pos = 4)
segments(2.8, 0.817-.1, 2.95, 0.817-.1, lwd = 4, col = "blue3")
segments(2.8, 0.783-.1, 2.95, 0.783-.1, lwd = 4, col = "darkorange")

# Refugee relocation experiment
trust <- read.csv("trust_ref_5pointscale.csv", header = TRUE)
line.hor <- seq(1, 5, 1)
xlab.trust <- c("Completely", "Largely", "Moderately", "A little bit", "Not at all")
xlabel.2 <- c("Refugee relocation")
par(mar=c(12.5, 13.5, 4, 0.5)) # set to size 2500 x 2000
plot(1, type="n", xaxt = 'n', yaxt = 'n', xlab="", ylab="", xlim=c(0.67, 5.33), ylim=c(0.35, 0.75))
box(lwd = 3) 
for(i in 1:10){
  abline(h=i/10, col = "grey", lty = 3, lwd = 3)
}
polygon(c(line.hor, rev(line.hor)), c(trust$noapp.ci.lower, rev(trust$noapp.ci.upper)),
        col = "darkorange", border = NA)
polygon(c(line.hor, rev(line.hor)), c(trust$app.ci.lower, rev(trust$app.ci.upper)),
        col = "blue3", border = NA)
rect(0, 0, 1, 1, density = NULL, col = "white", border = NA)
rect(5, 0, 6, 1, density = NULL, col = "white", border = NA)
box(lwd = 3) 
lines(x = c(1, 5), y = c(trust$noapp[1], trust$noapp[5]), lwd = 5) #point estimate: EU Council non-approval
lines(x = c(1, 5), y = c(trust$app[1], trust$app[5]), lwd = 5) #point estimate: EU Council approval
axis(side = 1, at = seq(1, 5, 1), labels = NA, line = 1, padj = 0, cex.axis = 4, lwd = 3, lwd.ticks = 3)
mtext(xlab.trust, side = 1, at = seq(1, 5, 1), line = 4, cex = 4)
mtext("Trust EU Council's judgment?", side = 1, at = 3, line = 9, padj = 0, cex = 4)
axis(side = 2, at = seq(0.4, 0.8, 0.1), labels = seq(0.4, 0.8, 0.1), line = 1, padj = 0, cex = 4, cex.axis = 4, cex.lab = 4, lwd = 3, lwd.ticks = 3)
mtext("Predicted support for refugee relocation", side = 2, at = 0.6, line = 8, padj = 0, cex = 4)
mtext(side = 3, xlabel.2, at = 3, cex = 4,font = 2, line = 1)
text(x = 3.0, y = 0.817-.1, "Policy endorsed by Council of EU", col = "blue3", cex = 4, pos = 4)
text(x = 3.0, y = 0.783-.1, "Policy not endorsed by Council of EU", col = "darkorange", cex = 4, pos = 4)
segments(2.8, 0.817-.1, 2.95, 0.817-.1, lwd = 4, col = "blue3")
segments(2.8, 0.783-.1, 2.95, 0.783-.1, lwd = 4, col = "darkorange")

# Figure A.3 in online appendix

# Note: run code to estimate models 25-26 below in order to calculate conditional effects shown in plot

# Economic recovery aid experiment
trust <- read.csv("trust_aid_pooled5.csv", header = TRUE)
line.hor <- seq(1, 5, 1)
xlab.trust <- c("Completely", "Largely", "Moderately", "A little bit", "Not at all")
xlabel.2 <- c("Coronavirus recovery aid")
par(mar=c(12.5, 13.5, 4, 0.5)) # set to size 2500 x 2000
plot(1, type="n", xaxt = 'n', yaxt = 'n', xlab="", ylab="", xlim=c(0.67, 5.33), ylim=c(-0.05, 0.15))
box(lwd = 3) 
for(i in 1:100){
  abline(h=(i/20)-0.1, col = "grey", lty = 3, lwd = 3)
}
polygon(c(line.hor, rev(line.hor)), c(trust$app.ci.lower, rev(trust$app.ci.upper)),
        col = "grey", border = NA)
abline(h = 0, lwd = 3)
rect(0, -1, 1, 1, density = NULL, col = "white", border = NA)
rect(5, -1, 6, 1, density = NULL, col = "white", border = NA)
box(lwd = 3) 
lines(x = c(1, 5), y = c(trust$app[1], trust$app[5]), lwd = 5) #point estimate: EU Council approval
axis(side = 1, at = seq(1, 5, 1), labels = NA, line = 1, padj = 0, cex.axis = 4, lwd = 3, lwd.ticks = 3)
mtext(xlab.trust, side = 1, at = seq(1, 5, 1), line = 4, cex = 4)
mtext("Trust EU Council's judgment?", side = 1, at = 3, line = 9, padj = 0, cex = 4)
axis(side = 2, at = seq(-0.05, 0.15, 0.05), labels = seq(-0.05, 0.15, 0.05), line = 1, padj = 0, cex = 4, cex.axis = 4, cex.lab = 4, lwd = 3, lwd.ticks = 3)
mtext("Conditional effect of EU Council approval", side = 2, at = 0.05, line = 8, padj = 0, cex = 4)
mtext(side = 3, xlabel.2, at = 3, cex = 4,font = 2, line = 1)

# Refugee relocation experiment
trust <- read.csv("trust_ref_pooled5.csv", header = TRUE)
line.hor <- seq(1, 5, 1)
xlab.trust <- c("Completely", "Largely", "Moderately", "A little bit", "Not at all")
xlabel.2 <- c("Refugee relocation")
par(mar=c(12.5, 13.5, 4, 0.5)) # set to size 2500 x 2000
plot(1, type="n", xaxt = 'n', yaxt = 'n', xlab="", ylab="", xlim=c(0.67, 5.33), ylim=c(-0.1, 0.15))
box(lwd = 3) 
for(i in 1:100){
  abline(h=(i/20)-0.1, col = "grey", lty = 3, lwd = 3)
}
polygon(c(line.hor, rev(line.hor)), c(trust$app.ci.lower, rev(trust$app.ci.upper)),
        col = "grey", border = NA)
abline(h = 0, lwd = 3)
rect(0, -1, 1, 1, density = NULL, col = "white", border = NA)
rect(5, -1, 6, 1, density = NULL, col = "white", border = NA)
box(lwd = 3) 
lines(x = c(1, 5), y = c(trust$app[1], trust$app[5]), lwd = 5) #point estimate: EU Council approval
axis(side = 1, at = seq(1, 5, 1), labels = NA, line = 1, padj = 0, cex.axis = 4, lwd = 3, lwd.ticks = 3)
mtext(xlab.trust, side = 1, at = seq(1, 5, 1), line = 4, cex = 4)
mtext("Trust EU Council's judgment?", side = 1, at = 3, line = 9, padj = 0, cex = 4)
axis(side = 2, at = seq(-0.1, 0.15, 0.05), labels = seq(-0.1, 0.15, 0.05), line = 1, padj = 0, cex = 4, cex.axis = 4, cex.lab = 4, lwd = 3, lwd.ticks = 3)
mtext("Conditional effect of EU Council approval", side = 2, at = 0.05, line = 8, padj = 0, cex = 4)
mtext(side = 3, xlabel.2, at = 3, cex = 4,font = 2, line = 1)

### Figure A.4 in online appendix

# Note: run code to estimate model 85 below in order to calculate conditional effects shown in plot

trust <- read.csv("trust_aid_pooled_eurobarometer.csv", header = TRUE)
line.hor <- seq(1, 4, 1)
xlab.trust <- c("Totally", "Tend to", "Tend not to", "Not at all")
xlabel.2 <- c("Coronavirus recovery aid")
par(mar=c(12.5, 13.5, 4, 0.5)) # looks good with 2500 x 2000
plot(1, type="n", xaxt = 'n', yaxt = 'n', xlab="", ylab="", xlim=c(0.67, 4.33), ylim=c(-.7, .7))
box(lwd = 3) 
for(i in 1:20){
  abline(h=(i/10)-1, col = "grey", lty = 3, lwd = 3)
}
polygon(c(line.hor, rev(line.hor)), c(trust$app.ci.lower, rev(trust$app.ci.upper)),
        col = "grey", border = NA)
abline(h = 0, lwd = 3)
rect(0, -1, 1, 1, density = NULL, col = "white", border = NA)
rect(4, -1, 5, 1, density = NULL, col = "white", border = NA)
box(lwd = 3) 
lines(x = c(1, 4), y = c(trust$app[1], trust$app[4]), lwd = 5) #point estimate: EU Council approval
axis(side = 1, at = seq(1, 4, 1), labels = NA, line = 1, padj = 0, cex.axis = 4, lwd = 3, lwd.ticks = 3)
mtext(xlab.trust, side = 1, at = seq(1, 4, 1), line = 4, cex = 4)
mtext("Trust EU Council's judgment?", side = 1, at = 2.5, line = 9, padj = 0, cex = 4)
axis(side = 2, at = seq(-0.7, 0.7, 0.1), labels = seq(-0.7, 0.7, 0.1), line = 1, padj = 0, cex = 4, cex.axis = 4, cex.lab = 4, lwd = 3, lwd.ticks = 3)
mtext("Conditional effect of European Council approval", side = 2, at = 0, line = 8, padj = 0, cex = 4)
mtext(side = 3, xlabel.2, at = 3, cex = 4,font = 2, line = 1)

### Analysis of original surveys containing experiments
#######################################################

### Tests of hypothesis 1: ANOVA

# Model 13: Coronavirus economic recovery aid experiment
recoveryaid$aideufac <- as.factor(recoveryaid$aideu)
recoveryaid$landfac <- as.factor(recoveryaid$land)
recoveryaid$femalefac <- as.factor(recoveryaid$female)
recoveryaid$educfac <- as.factor(recoveryaid$educ)
recoveryaid$agegroupfac <- as.factor(recoveryaid$agegroup) 
recoveryaid$galtanfac <- as.factor(recoveryaid$galtan)
recoveryaid$polinterestfac <- as.factor(recoveryaid$polinterest)
recoveryaid$forinterestfac <- as.factor(recoveryaid$forinterest)
recoveryaid$leftfac <- as.factor(recoveryaid$left)
recoveryaid$income1000fac <- as.factor(recoveryaid$income1000)
model.aid = aov(aiddvrescaled ~ aideufac + femalefac + educfac + agegroupfac + galtanfac + polinterestfac + forinterestfac + leftfac + income1000fac, data=recoveryaid)
options(contrasts=c(unordered="contr.sum", ordered="contr.poly"))
Anova(model.aid, type = "III")

# Model 14: refugee relocation experiment
refugeerelocation$refeufac <- as.factor(refugeerelocation$refeu)
refugeerelocation$landfac <- as.factor(refugeerelocation$land)
refugeerelocation$femalefac <- as.factor(refugeerelocation$female)
refugeerelocation$educfac <- as.factor(refugeerelocation$educ)
refugeerelocation$agegroupfac <- as.factor(refugeerelocation$agegroup) 
refugeerelocation$galtanfac <- as.factor(refugeerelocation$galtan)
refugeerelocation$polinterestfac <- as.factor(refugeerelocation$polinterest)
refugeerelocation$forinterestfac <- as.factor(refugeerelocation$forinterest)
refugeerelocation$leftfac <- as.factor(refugeerelocation$left)
refugeerelocation$income1000fac <- as.factor(refugeerelocation$income1000)
model.ref = aov(refdvrescaled ~ refeufac + femalefac + educfac + agegroupfac + galtanfac + polinterestfac + forinterestfac + leftfac + income1000fac, data=refugeerelocation)
options(contrasts=c(unordered="contr.sum", ordered="contr.poly"))
Anova(model.ref, type = "III")

# Model 15: Coronavirus economic recovery aid experiment
recoveryaid$aideufac <- as.factor(recoveryaid$aideu)
recoveryaid$landfac <- as.factor(recoveryaid$land)
recoveryaid$femalefac <- as.factor(recoveryaid$female)
recoveryaid$educfac <- as.factor(recoveryaid$educ)
recoveryaid$agegroupfac <- as.factor(recoveryaid$agegroup) 
recoveryaid$galtanfac <- as.factor(recoveryaid$galtan)
recoveryaid$polinterestfac <- as.factor(recoveryaid$polinterest)
recoveryaid$forinterestfac <- as.factor(recoveryaid$forinterest)
recoveryaid$leftfac <- as.factor(recoveryaid$left)
recoveryaid$income1000fac <- as.factor(recoveryaid$income1000)
model.aid = aov(aiddvrescaled ~ aideufac + femalefac + educfac + agegroupfac + galtanfac + polinterestfac + forinterestfac + leftfac + income1000fac, data=recoveryaid[recoveryaid$countryid == 1,])
options(contrasts=c(unordered="contr.sum", ordered="contr.poly"))
Anova(model.aid, type = "III")

# Model 16: refugee relocation experiment
refugeerelocation$refeufac <- as.factor(refugeerelocation$refeu)
refugeerelocation$landfac <- as.factor(refugeerelocation$land)
refugeerelocation$femalefac <- as.factor(refugeerelocation$female)
refugeerelocation$educfac <- as.factor(refugeerelocation$educ)
refugeerelocation$agegroupfac <- as.factor(refugeerelocation$agegroup) 
refugeerelocation$galtanfac <- as.factor(refugeerelocation$galtan)
refugeerelocation$polinterestfac <- as.factor(refugeerelocation$polinterest)
refugeerelocation$forinterestfac <- as.factor(refugeerelocation$forinterest)
refugeerelocation$leftfac <- as.factor(refugeerelocation$left)
refugeerelocation$income1000fac <- as.factor(refugeerelocation$income1000)
model.ref = aov(refdvrescaled ~ refeufac + femalefac + educfac + agegroupfac + galtanfac + polinterestfac + forinterestfac + leftfac + income1000fac, data=refugeerelocation[refugeerelocation$countryid == 1,])
options(contrasts=c(unordered="contr.sum", ordered="contr.poly"))
Anova(model.ref, type = "III")

# Model 17: Coronavirus economic recovery aid experiment
recoveryaid$aideufac <- as.factor(recoveryaid$aideu)
recoveryaid$landfac <- as.factor(recoveryaid$land)
recoveryaid$femalefac <- as.factor(recoveryaid$female)
recoveryaid$educfac <- as.factor(recoveryaid$educ)
recoveryaid$agegroupfac <- as.factor(recoveryaid$agegroup) 
recoveryaid$galtanfac <- as.factor(recoveryaid$galtan)
recoveryaid$polinterestfac <- as.factor(recoveryaid$polinterest)
recoveryaid$forinterestfac <- as.factor(recoveryaid$forinterest)
recoveryaid$leftfac <- as.factor(recoveryaid$left)
recoveryaid$income1000fac <- as.factor(recoveryaid$income1000)
model.aid = aov(aiddvrescaled ~ aideufac + femalefac + educfac + agegroupfac + galtanfac + polinterestfac + forinterestfac + leftfac + income1000fac, data=recoveryaid[recoveryaid$countryid == 2,])
options(contrasts=c(unordered="contr.sum", ordered="contr.poly"))
Anova(model.aid, type = "III")

# Model 18: refugee relocation experiment
refugeerelocation$refeufac <- as.factor(refugeerelocation$refeu)
refugeerelocation$landfac <- as.factor(refugeerelocation$land)
refugeerelocation$femalefac <- as.factor(refugeerelocation$female)
refugeerelocation$educfac <- as.factor(refugeerelocation$educ)
refugeerelocation$agegroupfac <- as.factor(refugeerelocation$agegroup) 
refugeerelocation$galtanfac <- as.factor(refugeerelocation$galtan)
refugeerelocation$polinterestfac <- as.factor(refugeerelocation$polinterest)
refugeerelocation$forinterestfac <- as.factor(refugeerelocation$forinterest)
refugeerelocation$leftfac <- as.factor(refugeerelocation$left)
refugeerelocation$income1000fac <- as.factor(refugeerelocation$income1000)
model.ref = aov(refdvrescaled ~ refeufac + femalefac + educfac + agegroupfac + galtanfac + polinterestfac + forinterestfac + leftfac + income1000fac, data=refugeerelocation[refugeerelocation$countryid == 2,])
options(contrasts=c(unordered="contr.sum", ordered="contr.poly"))
Anova(model.ref, type = "III")

### Tests of hypothesis 1: Pairwise comparisons of EU cue treatment conditions

# Table A.9 in Online Appendix: Coronavirus economic recovery aid experiment
recoveryaid$aideufac <- as.factor(recoveryaid$aideu)
pairwise.t.test(recoveryaid$aiddvrescaled, recoveryaid$aideufac, p.adjust.method = "BH") 

# Table A.10 in Online Appendix: refugee relocation experiment
refugeerelocation$refeufac <- as.factor(refugeerelocation$refeu)
pairwise.t.test(refugeerelocation$refdvrescaled, refugeerelocation$refeufac, p.adjust.method = "BH") 

# Table A.11 in Online Appendix: Coronavirus economic recovery aid experiment
recoveryaid$aideufac <- as.factor(recoveryaid$aideu)
pairwise.t.test(recoveryaid$aiddvrescaled[recoveryaid$countryid==1], recoveryaid$aideufac[recoveryaid$countryid==1], p.adjust.method = "BH") 

# Table A.12 in Online Appendix: refugee relocation experiment
refugeerelocation$refeufac <- as.factor(refugeerelocation$refeu)
pairwise.t.test(refugeerelocation$refdvrescaled[refugeerelocation$countryid==1], refugeerelocation$refeufac[refugeerelocation$countryid==1], p.adjust.method = "BH") 

# Table A.13 in Online Appendix: Coronavirus economic recovery aid experiment
recoveryaid$aideufac <- as.factor(recoveryaid$aideu)
pairwise.t.test(recoveryaid$aiddvrescaled[recoveryaid$countryid==2], recoveryaid$aideufac[recoveryaid$countryid==2], p.adjust.method = "BH") 

# Table A.14 in Online Appendix: refugee relocation experiment
refugeerelocation$refeufac <- as.factor(refugeerelocation$refeu)
pairwise.t.test(refugeerelocation$refdvrescaled[refugeerelocation$countryid==2], refugeerelocation$refeufac[refugeerelocation$countryid==2], p.adjust.method = "BH") 

### Tests of hypothesis 2: Moderation analyses (Hayes, 2022)

# Model 25: Coronavirus economic recovery aid experiment
# Note: run process.R do file before estimating models 25-30
process(data = recoveryaid, y = "aiddvrescaled", x = "aidapp", w = "trusteuaid5", model = 1, moments = 1, modelbt = 1, boot = 10000, seed = 20230401, jn = 1,
        cov = c("female", "educ2", "educ3", "educ4", "age", "galtan", "polinterest", "forinterest", "left", "income1000", "trustdeaid"))

# Model 26: refugee relocation experiment
# Note: run process.R do file before estimating models 25-30
process(data = refugeerelocation, y = "refdvrescaled", x = "refapp", w = "trusteuref5", model = 1, moments = 1, modelbt = 1, boot = 10000, seed = 20230401, jn = 1,
        cov = c("female", "educ2", "educ3", "educ4", "age", "galtan", "polinterest", "forinterest", "left", "income1000", "trustderef"))

# Model 27: Coronavirus economic recovery aid experiment
# Note: run process.R do file before estimating models 25-30
process(data = recoveryaid[recoveryaid$countryid == 1,], y = "aiddvrescaled", x = "aidapp", w = "trusteuaid5", model = 1, moments = 1, modelbt = 1, boot = 10000, seed = 20230401, jn = 1,
        cov = c("female", "educ2", "educ3", "educ4", "age", "galtan", "polinterest", "forinterest", "left", "income1000", "trustdeaid"))

# Model 28: refugee relocation experiment
# Note: run process.R do file before estimating models 25-30
process(data = refugeerelocation[refugeerelocation$countryid == 1,], y = "refdvrescaled", x = "refapp", w = "trusteuref5", model = 1, moments = 1, modelbt = 1, boot = 10000, seed = 20230401, jn = 1,
        cov = c("female", "educ2", "educ3", "educ4", "age", "galtan", "polinterest", "forinterest", "left", "income1000", "trustderef"))

# Model 29: Coronavirus economic recovery aid experiment
# Note: run process.R do file before estimating models 25-30
process(data = recoveryaid[recoveryaid$countryid == 2,], y = "aiddvrescaled", x = "aidapp", w = "trusteuaid5", model = 1, moments = 1, modelbt = 1, boot = 10000, seed = 20230401, jn = 1,
        cov = c("female", "educ2", "educ3", "educ4", "age", "galtan", "polinterest", "forinterest", "left", "income1000", "trustdeaid"))

# Model 30: refugee relocation experiment
# Note: run process.R do file before estimating models 25-30
process(data = refugeerelocation[refugeerelocation$countryid == 2,], y = "refdvrescaled", x = "refapp", w = "trusteuref5", model = 1, moments = 1, modelbt = 1, boot = 10000, seed = 20230401, jn = 1,
        cov = c("female", "educ2", "educ3", "educ4", "age", "galtan", "polinterest", "forinterest", "left", "income1000", "trustderef"))

### Quasi-experimental analysis of Eurobarometer data
#####################################################

### Tests of hypothesis 2: Moderation analyses (Hayes, 2022)

# Model 85: quasi-experimental analyses of Eurobarometer data
process(data = eurobarometer.subset, y = "financialsupport", x = "aftereusummit", w = "trusteucorona", model = 1, moments = 1, modelbt = 1, boot = 10000, seed = 20230401, jn = 1,
        cov = c("female", "age", "incomecat2", "incomecat3", "educ2", "educ3", "educ4", "educ5", "polinterest", "eurinterest", "left", "leftsq"))
